#include "log.h"

LOG::LOG(char *pLogName)
{
    strLogName = std::string(pLogName);
    strFuncName = "";
}
/*
* function for LOG to set log file name and function name
*/
LOG::LOG(char *pLogName, char *pFuncName)
{


    strFuncName = std::string(pFuncName);
}
/*
* function for LOG to make LOG1 = LOG2
*/
LOG LOG::operator=(const LOG log)
{
    //this's strFuncName, strLogName, mParamInfo set
    //as log
    strFuncName = log.strFuncName;
    strLogName = log.strLogName;
    this->mParamInfo.clear();
    std::map<std::string, std::string> l_mParams = getParams();
    for (std::map<std::string, std::string>::iterator i = l_mParams.begin(); i != l_mParams.end(); ++i)
        mParamInfo.insert(*i);
    return *this;
}

LOG LOG::operator+=(const LOG log)
{
    std::map<std::string, std::string> l_mParams = getParams();
    for (std::map<std::string, std::string>::iterator i = l_mParams.begin(); i != l_mParams.end(); ++i)
        mParamInfo.insert(*i);
    return *this;
}

int LOG::setLogName(char *pLogName)
{
    if (!pLogName)
        return 0;
    strLogName = std::string(pLogName);
    return 1;
}

int LOG::setFuncName(char *pFuncName)
{
    if (!pFuncName)
        return 0;
    strFuncName = std::string(pFuncName);
    return 1;
}

int LOG::logWrite()
{
    //write log

    return 1;
}

std::map<std::string, std::string> LOG::getParams()
{
    std::map<std::string, std::string> l_mParams;
    l_mParams = mParamInfo;
    return l_mParams;
}

LOG::~LOG()
{
    strLogName = "";
    strFuncName = "";
    //clear map
    mParamInfo.clear();
}
